$(function () {
  let form = layui.form
  let layer = layui.layer
  let layui_form = document.querySelector('.layui-form')
  form.on('submit(formDemo)', function (data) {
    let formData = new FormData(layui_form)
    let str = ''
    let arr = []
    formData.forEach((value, key) => {
      str += `${key}=${value}&`
      arr.push(value)
    });
    let newstr = str.slice(0, -1)
    if (arr[1] !== arr[2]) {
      layer.msg('两次密码不同')
      return false
    }
    axios.post('/my/updatepwd', newstr)
      .then(res => {
        if (res.data.status === 1) {
          return layer.msg('原密码错误')
        }
        layer.msg('更新密码成功')
      })
    return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
  });
})